<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Spec::Runner::BehaviourRunner</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Spec::Runner::BehaviourRunner</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/plugins/rspec/lib/spec/runner/behaviour_runner_rb.html">
                vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000223">add_behaviour</a>&nbsp;&nbsp;
      <a href="#M000222">new</a>&nbsp;&nbsp;
      <a href="#M000229">number_of_examples</a>&nbsp;&nbsp;
      <a href="#M000227">prepare!</a>&nbsp;&nbsp;
      <a href="#M000226">report_dump</a>&nbsp;&nbsp;
      <a href="#M000225">report_end</a>&nbsp;&nbsp;
      <a href="#M000224">run</a>&nbsp;&nbsp;
      <a href="#M000228">run_behaviours</a>&nbsp;&nbsp;
      <a href="#M000231">sort_paths</a>&nbsp;&nbsp;
      <a href="#M000230">sorter</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">


    <div id="constants-list">
      <h3 class="section-bar">Constants</h3>

      <div class="name-list">
        <table summary="Constants">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">FILE_SORTERS</td>
          <td>=</td>
          <td class="context-item-value">{         'mtime' =&gt; lambda {|file_a, file_b| File.mtime(file_b) &lt;=&gt; File.mtime(file_a)}</td>
        </tr>
        </table>
      </div>
    </div>



      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000222" class="method-detail">
        <a name="M000222"></a>

        <div class="method-heading">
          <a href="#M000222" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(options, arg=nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000222-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000222-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb, line 5</span>
5:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>, <span class="ruby-identifier">arg</span>=<span class="ruby-keyword kw">nil</span>)
6:         <span class="ruby-ivar">@behaviours</span> = []
7:         <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">options</span>
8:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000223" class="method-detail">
        <a name="M000223"></a>

        <div class="method-heading">
          <a href="#M000223" class="method-signature">
          <span class="method-name">add_behaviour</span><span class="method-args">(behaviour)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000223-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000223-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb, line 10</span>
10:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_behaviour</span>(<span class="ruby-identifier">behaviour</span>)
11:         <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">specified_examples</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">specified_examples</span>.<span class="ruby-identifier">empty?</span>
12:           <span class="ruby-identifier">behaviour</span>.<span class="ruby-identifier">retain_examples_matching!</span>(<span class="ruby-identifier">specified_examples</span>)
13:         <span class="ruby-keyword kw">end</span>
14:         <span class="ruby-ivar">@behaviours</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">behaviour</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">behaviour</span>.<span class="ruby-identifier">number_of_examples</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">behaviour</span>.<span class="ruby-identifier">shared?</span>
15:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000229" class="method-detail">
        <a name="M000229"></a>

        <div class="method-heading">
          <a href="#M000229" class="method-signature">
          <span class="method-name">number_of_examples</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000229-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000229-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb, line 62</span>
62:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">number_of_examples</span>
63:         <span class="ruby-ivar">@behaviours</span>.<span class="ruby-identifier">inject</span>(<span class="ruby-value">0</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">sum</span>, <span class="ruby-identifier">behaviour</span><span class="ruby-operator">|</span> <span class="ruby-identifier">sum</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">behaviour</span>.<span class="ruby-identifier">number_of_examples</span>}
64:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000227" class="method-detail">
        <a name="M000227"></a>

        <div class="method-heading">
          <a href="#M000227" class="method-signature">
          <span class="method-name">prepare!</span><span class="method-args">(paths)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000227-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000227-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb, line 45</span>
45:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">prepare!</span>(<span class="ruby-identifier">paths</span>)
46:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">paths</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-comment cmt"># It's nil when running single specs with ruby</span>
47:           <span class="ruby-identifier">paths</span> = <span class="ruby-identifier">find_paths</span>(<span class="ruby-identifier">paths</span>)
48:           <span class="ruby-identifier">sorted_paths</span> = <span class="ruby-identifier">sort_paths</span>(<span class="ruby-identifier">paths</span>)
49:           <span class="ruby-identifier">load_specs</span>(<span class="ruby-identifier">sorted_paths</span>) <span class="ruby-comment cmt"># This will populate @behaviours via callbacks to add_behaviour</span>
50:         <span class="ruby-keyword kw">end</span>
51:         <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">reporter</span>.<span class="ruby-identifier">start</span>(<span class="ruby-identifier">number_of_examples</span>)
52:         <span class="ruby-ivar">@behaviours</span>.<span class="ruby-identifier">reverse!</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">reverse</span>
53:         <span class="ruby-identifier">set_sequence_numbers</span>
54:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000226" class="method-detail">
        <a name="M000226"></a>

        <div class="method-heading">
          <a href="#M000226" class="method-signature">
          <span class="method-name">report_dump</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000226-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000226-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb, line 41</span>
41:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">report_dump</span>
42:         <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">reporter</span>.<span class="ruby-identifier">dump</span>
43:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000225" class="method-detail">
        <a name="M000225"></a>

        <div class="method-heading">
          <a href="#M000225" class="method-signature">
          <span class="method-name">report_end</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000225-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000225-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb, line 37</span>
37:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">report_end</span>
38:         <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">reporter</span>.<span class="ruby-identifier">end</span>
39:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000224" class="method-detail">
        <a name="M000224"></a>

        <div class="method-heading">
          <a href="#M000224" class="method-signature">
          <span class="method-name">run</span><span class="method-args">(paths, exit_when_done)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Runs all behaviours and returns the number of failures.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000224-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000224-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb, line 18</span>
18:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run</span>(<span class="ruby-identifier">paths</span>, <span class="ruby-identifier">exit_when_done</span>)
19:         <span class="ruby-identifier">prepare!</span>(<span class="ruby-identifier">paths</span>)
20:         <span class="ruby-keyword kw">begin</span>
21:           <span class="ruby-identifier">run_behaviours</span>
22:         <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Interrupt</span>
23:         <span class="ruby-keyword kw">ensure</span>
24:           <span class="ruby-identifier">report_end</span>
25:         <span class="ruby-keyword kw">end</span>
26:         <span class="ruby-identifier">failure_count</span> = <span class="ruby-identifier">report_dump</span>
27:         
28:         <span class="ruby-identifier">heckle</span> <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">failure_count</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-ivar">@options</span>.<span class="ruby-identifier">heckle_runner</span>.<span class="ruby-identifier">nil?</span>)
29:         
30:         <span class="ruby-keyword kw">if</span>(<span class="ruby-identifier">exit_when_done</span>)
31:           <span class="ruby-identifier">exit_code</span> = (<span class="ruby-identifier">failure_count</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>) <span class="ruby-operator">?</span> <span class="ruby-value">0</span> <span class="ruby-operator">:</span> <span class="ruby-value">1</span>
32:           <span class="ruby-identifier">exit</span>(<span class="ruby-identifier">exit_code</span>)
33:         <span class="ruby-keyword kw">end</span>
34:         <span class="ruby-identifier">failure_count</span>
35:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000228" class="method-detail">
        <a name="M000228"></a>

        <div class="method-heading">
          <a href="#M000228" class="method-signature">
          <span class="method-name">run_behaviours</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000228-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000228-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb, line 56</span>
56:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">run_behaviours</span>
57:         <span class="ruby-ivar">@behaviours</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">behaviour</span><span class="ruby-operator">|</span>
58:           <span class="ruby-identifier">behaviour</span>.<span class="ruby-identifier">run</span>(<span class="ruby-ivar">@options</span>.<span class="ruby-identifier">reporter</span>, <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">dry_run</span>, <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">reverse</span>, <span class="ruby-ivar">@options</span>.<span class="ruby-identifier">timeout</span>)
59:         <span class="ruby-keyword kw">end</span>
60:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000231" class="method-detail">
        <a name="M000231"></a>

        <div class="method-heading">
          <a href="#M000231" class="method-signature">
          <span class="method-name">sort_paths</span><span class="method-args">(paths)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000231-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000231-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb, line 74</span>
74:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sort_paths</span>(<span class="ruby-identifier">paths</span>)
75:         <span class="ruby-identifier">sorter</span> = <span class="ruby-identifier">sorter</span>(<span class="ruby-identifier">paths</span>)
76:         <span class="ruby-identifier">paths</span> = <span class="ruby-identifier">paths</span>.<span class="ruby-identifier">sort</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">sorter</span>) <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">sorter</span>.<span class="ruby-identifier">nil?</span>
77:         <span class="ruby-identifier">paths</span>
78:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000230" class="method-detail">
        <a name="M000230"></a>

        <div class="method-heading">
          <a href="#M000230" class="method-signature">
          <span class="method-name">sorter</span><span class="method-args">(paths)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000230-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000230-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/runner/behaviour_runner.rb, line 70</span>
70:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sorter</span>(<span class="ruby-identifier">paths</span>)
71:         <span class="ruby-constant">FILE_SORTERS</span>[<span class="ruby-ivar">@options</span>.<span class="ruby-identifier">loadby</span>]
72:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>